<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>栅格分段专题图</title>

    <link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css">
    <link rel="stylesheet" href="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.css">
</head>
<body style=" margin: 0;overflow: hidden;background: #fff;width: 100%;height:100%;position: absolute;top: 0;">
<div id="map" style="margin:0 auto;width: 100%;height: 100%"></div>

<script type="text/javascript" src="http://cdn.bootcss.com/leaflet/1.0.3/leaflet.js"></script>
<script type="text/javascript" src="../../dist/iclient9-leaflet.min.js"></script>
<script type="text/javascript">
    var map, themeService, themeGridRange, themeParameters, themeLayer,
            url = "http://support.supermap.com.cn:8090/iserver/services/map-jingjin/rest/maps/京津地区人口分布图_专题图";
    map = L.map('map', {
        crs: L.CRS.EPSG4326,
        center: [40, 117],
        maxZoom: 18,
        zoom: 6
    });
    L.supermap.tiledMapLayer(url, {noWrap: true}).addTo(map);
    createTheme();

    function createTheme() {
        themeService = L.supermap.themeService(url);
        var themeGridRangeItem1 = new SuperMap.ThemeGridRangeItem({
                    start: -4,
                    end: 120,
                    color: new SuperMap.ServerColor(198, 244, 240)
                }),

                themeGridRangeItem2 = new SuperMap.ThemeGridRangeItem({
                    start: 120,
                    end: 240,
                    color: new SuperMap.ServerColor(176, 244, 188)
                }),
                themeGridRangeItem3 = new SuperMap.ThemeGridRangeItem({
                    start: 240,
                    end: 360,
                    color: new SuperMap.ServerColor(218, 251, 178)
                }),
                themeGridRangeItem4 = new SuperMap.ThemeGridRangeItem({
                    start: 360,
                    end: 480,
                    color: new SuperMap.ServerColor(220, 236, 145)
                }),
                themeGridRangeItem5 = new SuperMap.ThemeGridRangeItem({
                    start: 480,
                    end: 600,
                    color: new SuperMap.ServerColor(96, 198, 66)
                }),
                themeGridRangeItem6 = new SuperMap.ThemeGridRangeItem({
                    start: 600,
                    end: 720,
                    color: new SuperMap.ServerColor(20, 142, 53)
                }),
                themeGridRangeItem7 = new SuperMap.ThemeGridRangeItem({
                    start: 720,
                    end: 840,
                    color: new SuperMap.ServerColor(85, 144, 55)
                }),

                themeGridRangeItem8 = new SuperMap.ThemeGridRangeItem({
                    start: 840,
                    end: 960,
                    color: new SuperMap.ServerColor(171, 168, 38)
                }),
                themeGridRangeItem9 = new SuperMap.ThemeGridRangeItem({
                    start: 960,
                    end: 1100,
                    color: new SuperMap.ServerColor(235, 165, 9)
                }),
                themeGridRangeItem10 = new SuperMap.ThemeGridRangeItem({
                    start: 1100,
                    end: 1220,
                    color: new SuperMap.ServerColor(203, 89, 2)
                }),
                themeGridRangeItem11 = new SuperMap.ThemeGridRangeItem({
                    start: 1220,
                    end: 1340,
                    color: new SuperMap.ServerColor(157, 25, 1)
                }),
                themeGridRangeItem12 = new SuperMap.ThemeGridRangeItem({
                    start: 1340,
                    end: 1460,
                    color: new SuperMap.ServerColor(118, 15, 3)
                }),
                themeGridRangeItem13 = new SuperMap.ThemeGridRangeItem({
                    start: 1460,
                    end: 1600,
                    color: new SuperMap.ServerColor(112, 32, 7)
                }),

                themeGridRangeItem14 = new SuperMap.ThemeGridRangeItem({
                    start: 1600,
                    end: 1800,
                    color: new SuperMap.ServerColor(106, 45, 12)
                }),
                themeGridRangeItem15 = new SuperMap.ThemeGridRangeItem({
                    start: 1800,
                    end: 2000,
                    color: new SuperMap.ServerColor(129, 80, 50)
                }),
                themeGridRangeItem16 = new SuperMap.ThemeGridRangeItem({
                    start: 2000,
                    end: 2167,
                    color: new SuperMap.ServerColor(160, 154, 146)
                });
        themeGridRange = new SuperMap.ThemeGridRange({
            reverseColor: false,
            rangeMode: SuperMap.RangeMode.EQUALINTERVAL,
            items: [
                themeGridRangeItem1, themeGridRangeItem2,
                themeGridRangeItem3, themeGridRangeItem4,
                themeGridRangeItem5, themeGridRangeItem6,
                themeGridRangeItem7, themeGridRangeItem8,
                themeGridRangeItem9, themeGridRangeItem10,
                themeGridRangeItem11, themeGridRangeItem12,
                themeGridRangeItem13, themeGridRangeItem14,
                themeGridRangeItem15, themeGridRangeItem16
            ]
        });
        themeParameters = new SuperMap.ThemeParameters({
            datasetNames: ["JingjinTerrain"],
            dataSourceNames: ["Jingjin"],
            joinItems: null,
            themes: [themeGridRange]
        });
        themeService.getThemeInfo(themeParameters, function (serviceResult) {
            var result = serviceResult.result;
            if (result && result.newResourceID) {
                themeLayer = L.supermap.tiledMapLayer(url, {
                    noWrap: true,
                    cacheEnabled: false,
                    transparent: true,
                    layersID: result.newResourceID
                }).addTo(map);
            }
        });
    }
</script>
</body>
</html>